#obj-m += malloc_test.o
#obj-m += kzalloc_test.o
obj-m += ltc2942_driver.o
PWD := $(shell pwd)

ifeq (1,0)

ARCH = arm

CROSS_COMPILE = arm-linux-gnueabi-

KDIR = /home/ubuntu/runningLinux/runninglinuxkernel_4.0

endif

OUTPUT = ${KDIR}/kmodules


ifeq ($(ARCH),)
ARCH := $(shell uname -m)
endif
ifeq ($(CROSS_COMPILE),)
CROSS_COMPILE :=
endif
ifeq ($(KDIR),)
KDIR := /lib/modules/$(shell uname -r)/build
ifeq ($(ARCH),i686)
ifeq ($(wildcard $KDIR/arch/$ARCH),)
ARCH=i386
endif
endif
endif

#KBUILD_CFLAGS += -fno-pic 

default:
	ln -sf makefile Makefile
	$(MAKE) ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} -C $(KDIR) M=$(PWD) modules
	rm -rf Makefile
	rm -rf *.o *~ core .depend .*.cmd  *.mod.c .tmp_versions Module.* modules.order *.mod

install:
	insmod *.ko

uninstall:
	rmmod *.ko

clean:
	rm -rf Makefile
	rm -rf *.o *~ core .depend .*.cmd  *.mod.c .tmp_versions Module.* modules.order *.mod *.ko
